package com.example.mybatis_plus_use.dto;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.example.mybatis_plus_use.ValidationGroups.ValidationGroups;
import com.example.mybatis_plus_use.ValidationGroups.ValidationGroups.UpdateGroup;
import com.example.mybatis_plus_use.ValidationGroups.ValidationGroups.RegisterGroup;
import com.example.mybatis_plus_use.ValidationGroups.ValidationGroups.LoginGroup;
import com.example.mybatis_plus_use.enums.Education;
import jakarta.validation.constraints.*;
import lombok.Data;

@Data
public class UserRegisterDto {

    @NotBlank(message = "用户名不能为空", groups = {RegisterGroup.class, UpdateGroup.class})
    @Size(min = 2, max = 20, message = "用户名长度必须在2-20之间",
            groups = {RegisterGroup.class, UpdateGroup.class})
    private String username;

    @NotBlank(message = "邮箱不能为空", groups = {RegisterGroup.class, UpdateGroup.class})
    @Email(message = "邮箱格式不正确", groups = {RegisterGroup.class, UpdateGroup.class})
    private String email;

    @NotBlank(message = "密码不能为空", groups = RegisterGroup.class)
    @Pattern(
            regexp = "^(?=.*[a-z])(?=.*[A-Z])(?=.*\\d)[a-zA-Z\\d]{6,}$",
            message = "密码必须包含大小写字母和数字，长度至少8位",
            groups = RegisterGroup.class
    )
    private String password;

    @NotNull(message = "年龄不能为空", groups = {RegisterGroup.class, UpdateGroup.class})
    @Min(value = 0, message = "年龄不能小于0", groups = {RegisterGroup.class, UpdateGroup.class})
    @Max(value = 150, message = "年龄不能大于150", groups = {RegisterGroup.class, UpdateGroup.class})
    private Integer age;

    @NotBlank(message = "性别不能为空", groups = {RegisterGroup.class, UpdateGroup.class})
    @Pattern(regexp = "^(男|女)$", message = "性别只能是男或女",
            groups = {RegisterGroup.class, UpdateGroup.class})
    private String sex;

    @NotNull(message = "学历不能为空", groups = {RegisterGroup.class, UpdateGroup.class})
    private Education education;
}
